package xj.graph2d.app.diagram;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenuItem;

import xj.graph2d.GraphDocument;
import xj.graph2d.SimpleDrawDocument;
import xj.graph2d.SimpleDrawView;
import xj.graph2d.app.DrawAction;

public class LayoutDiagramListener 
  extends DrawAction 
  implements ActionListener {

  public void actionPerformed(ActionEvent e) {
    if (e != null) {
      Object src = e.getSource();
      if (src != null && src instanceof JMenuItem) {
	JMenuItem b = (JMenuItem) src;
	String cmd = b.getActionCommand();

	if (main != null) {
	  SimpleDrawDocument doc = main.getDoc();
	  SimpleDrawView view = main.getView();
	  if (doc instanceof GraphDocument) {
	    GraphDocument graph = (GraphDocument) doc;
	    graph.doLayout();
	    view.repaint();
	  }
	}
      }
    }
  }

}